﻿<UserControl x:Class="SoftTeach.View.Stundenentwürfe.StundenentwurfDetailView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:softTeach="clr-namespace:SoftTeach"
             xmlns:converter="clr-namespace:SoftTeach.Resources.Converter" mc:Ignorable="d" 
             xmlns:dd="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
             xmlns:pb="clr-namespace:SoftTeach.ViewModel.Helper.PushBinding"
             xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
             xmlns:controls="clr-namespace:SoftTeach.Resources.Controls"
             xmlns:system="clr-namespace:System;assembly=mscorlib"
             d:DesignHeight="400" d:DesignWidth="600">
  <UserControl.Resources>
    <CollectionViewSource x:Key="SortedPhasenViewSource" Source="{Binding Path=Phasen}" IsLiveSortingRequested="True" >
      <CollectionViewSource.LiveSortingProperties>
        <system:String>AbfolgeIndex</system:String>
      </CollectionViewSource.LiveSortingProperties>
      <CollectionViewSource.SortDescriptions>
        <componentModel:SortDescription PropertyName="AbfolgeIndex" Direction="Ascending" />
      </CollectionViewSource.SortDescriptions>
    </CollectionViewSource>
    <converter:IgnoreNewItemPlaceHolderConverter x:Key="IgnoreNewItemPlaceHolderConverter"/>
  </UserControl.Resources>
  <GroupBox Padding="5" Header="Stundenentwurf" Margin="5" HeaderTemplate="{StaticResource GroupBoxHeader}">
    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>
      <Grid Grid.Row="0" x:Name="TopGrid">
        <Grid>
          <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
          </Grid.ColumnDefinitions>
          <GroupBox Grid.Column="0" Margin="5" Header="Thema">
            <Grid>
              <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
              </Grid.RowDefinitions>
              <TextBox Grid.Row="0" Style="{StaticResource Header1}" Text="{Binding Path=StundenentwurfStundenthema}">
                <TextBox.Background>
                  <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="White" Offset="0.664" />
                    <GradientStop Color="#FFF8F8F8" Offset="0" />
                  </LinearGradientBrush>
                </TextBox.Background>
              </TextBox>
              <ComboBox Grid.Row="1" Margin="0,6" Height="23" SelectedValuePath="." 
                    SelectedItem="{Binding Path=StundenentwurfModul}" 
                    ItemsSource="{Binding Path=ModulView}" 
                    DisplayMemberPath="ModulBezeichnung"
                    HorizontalAlignment="Stretch"
                    Style="{StaticResource {x:Static ToolBar.ComboBoxStyleKey}}"/>
            </Grid>
          </GroupBox>
          <GroupBox Grid.Column="1" Margin="5" Header="Unterlagen">
            <Grid>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
              </Grid.ColumnDefinitions>
              <StackPanel Grid.Column="0" Orientation="Vertical">
                <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=AddDateiverweisCommand}">
                  <StackPanel Orientation="Horizontal" ToolTip="Datei hinzufügen">
                    <Grid >
                      <Image Source="/SoftTeach;component/Images/Dateityp16.png"/>
                      <Image Source="/SoftTeach;component/Images/AddOverlay16.png"/>
                    </Grid>
                  </StackPanel>
                </Button>

                <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=DeleteDateiverweisCommand}">
                  <StackPanel Orientation="Horizontal" ToolTip="Datei entfernen">
                    <Grid >
                      <Image Source="/SoftTeach;component/Images/Dateityp16.png"/>
                      <Image Source="/SoftTeach;component/Images/RemoveOverlay16.png"/>
                    </Grid>
                  </StackPanel>
                </Button>
              </StackPanel>
              <ListView Grid.Column="1" 
                 SelectedItem="{Binding Path=CurrentDateiverweis, Mode=TwoWay}" 
                 ItemsSource="{Binding Path=Dateiverweise}"
                 ItemTemplate="{StaticResource DateiverweiseListViewTile}"
                  >
                <ListView.ItemsPanel>
                  <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal"/>
                  </ItemsPanelTemplate>
                </ListView.ItemsPanel>
              </ListView>
            </Grid>
          </GroupBox>
        </Grid>
      </Grid>
      <GroupBox Grid.Row="1" Header="Phasen" Margin="5">
        <Grid>
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
          </Grid.RowDefinitions>
          <Grid Grid.Row="0" Margin="3">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*"/>
              <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Column="0" Orientation="Horizontal">
              <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=MovePhaseCommand}">
                <StackPanel Orientation="Horizontal" ToolTip="Phase verschieben">
                  <Grid >
                    <Image Source="/SoftTeach;component/Images/Phase16.png"/>
                    <Image Source="/SoftTeach;component/Images/MoveOverlay16.png"/>
                  </Grid>
                  <Label Padding="5,0,0,0" VerticalContentAlignment="Center">Phase in nächste Stunde verschieben.</Label>

                </StackPanel>
              </Button>
            </StackPanel>
            <Border Grid.Column="1" CornerRadius="5" Background="{Binding Path=StundentwurfMinutenCheckBrush}">
              <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
                <Label Padding="3">Verplante Minuten:</Label>
                <Label Padding="3" Content="{Binding Path=StundenentwurfVerplanteMinutenVonAllen}"/>
              </StackPanel>
            </Border>
          </Grid>
          <!--CellStyle="{StaticResource CellDirectClickStyle}"-->
          <controls:SDataGrid 
            Grid.Row="1" 
            SelectedItem="{Binding Path=CurrentPhase, Converter={StaticResource IgnoreNewItemPlaceHolderConverter}}" 
            ItemsSource="{Binding Source={StaticResource SortedPhasenViewSource}}" 
            DataGridCell.Selected="PhasenGrid_OnCellSelected"
                  AutoGenerateColumns="False"
                  HorizontalScrollBarVisibility="Disabled"
                  x:Name="PhasenGrid"
                  dd:DragDrop.IsDragSource="True" 
                  dd:DragDrop.IsDropTarget="True"
                  dd:DragDrop.DragAdornerTemplate="{StaticResource PhaseDragAdorner}"
                  dd:DragDrop.DropHandler="{Binding}" 
                  SelectionMode="Extended">
            <pb:PushBindingManager.PushBindings>
              <pb:PushBinding TargetProperty="SelectedItems" Path="SelectedPhasen"/>
            </pb:PushBindingManager.PushBindings>
            <DataGrid.InputBindings>
              <KeyBinding Modifiers="Control" Key="C" Command="{Binding Path=CopyCommand}"/>
              <KeyBinding Modifiers="Control" Key="V" Command="{Binding Path=PasteCommand}"/>
            </DataGrid.InputBindings>
            <DataGrid.Columns>
              <DataGridTextColumn Header="Zeit" Binding="{Binding Path=PhaseZeit, UpdateSourceTrigger=PropertyChanged}"/>
              <DataGridComboBoxColumn 
                        Header="Medien" 
                        ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Medien}"
                        SelectedItemBinding="{Binding Path=PhaseMedium}" 
                        DisplayMemberPath="MediumBezeichnung"
                        EditingElementStyle="{StaticResource DatagridComboBoxElementStyle}"/>
              <DataGridComboBoxColumn 
                        Header="Sozialform" 
                        SelectedItemBinding="{Binding Path=PhaseSozialform}" 
                        DisplayMemberPath="SozialformBezeichnung"
                        EditingElementStyle="{StaticResource DatagridComboBoxElementStyle}"
                        ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Sozialformen}"/>
              <DataGridTextColumn Header="Inhalt" Binding="{Binding Path=PhaseInhalt}" Width="*"
                            ElementStyle="{StaticResource DatagridMultilineElementStyle}"
                            EditingElementStyle="{StaticResource DatagridMultilineEditingElementStyle}"/>
            </DataGrid.Columns>
          </controls:SDataGrid>
        </Grid>
      </GroupBox>
      <Grid Grid.Row="2" x:Name="BottomGrid">
        <Grid.ColumnDefinitions>
          <ColumnDefinition/>
          <ColumnDefinition/>
          <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <GroupBox Grid.Column="0" Margin="5" Header="Hausaufgaben">
          <TextBox Height="45" Name="HausaufgabenTextBox" Text="{Binding Path=StundenentwurfHausaufgaben}"
                   TextWrapping="Wrap"
                   AcceptsReturn="True"/>
        </GroupBox>
        <GroupBox Grid.Column="1" Margin="5" Header="Termine/Ansagen">
          <TextBox Height="45" Name="TermineTextBox" Text="{Binding Path=StundenentwurfAnsagen}"
                   TextWrapping="Wrap"
                   AcceptsReturn="True"/>
        </GroupBox>
        <GroupBox Grid.Column="2" Margin="5" Header="Sonstiges">
          <StackPanel>
            <CheckBox Content="Kopieren" Height="16" Name="KopierenCheckBox" IsChecked="{Binding Path=StundenentwurfKopieren}"/>
            <CheckBox Content="Computer" Height="16" Name="ComputerCheckBox" IsChecked="{Binding Path=StundenentwurfComputer}"/>
          </StackPanel>
        </GroupBox>
      </Grid>
    </Grid>
  </GroupBox>
</UserControl>
